package stool.singletonpattern.part4;

import java.lang.reflect.Constructor;

/**
 * @Author Felix YF Dong
 * @Date 2021/5/12
 * @Description 测试反射
 */
public class Main {

    public static void main(String[] args) throws Exception {

        Singleton singleton1 = Singleton.getSingleton();

        Class<Singleton> classType = Singleton.class;
        Constructor<Singleton> constructor = classType.getDeclaredConstructor((Class<?>[]) null);
        constructor.setAccessible(true);
        Singleton singleton2 = constructor.newInstance();

//        Singleton singleton2 = Singleton.getSingleton();

        if (singleton1 == singleton2) {
            System.out.println("Y");
        } else {
            System.out.println("N");
        }
    }
}
